/******************************************************/
/* Goblin's Cube - Rubik's cube game for Wii Homebrew */
/* Copyright (C) 2009 Ricardo Bueno Cordeiro          */
/* Licensed under de GNU General Public License v2.0  */
/*   See license_gplv2.txt for detalis                */
/******************************************************/

#ifndef __SOUND_H_
#define __SOUND_H_

#include <gccore.h>

#define SOUND_NUM_SOUNDS 4

struct riff_file_t {
	u32 riff;
	u32 total_size;
} __attribute__ ((packed));

struct wave_header_t {
	u32 wave;
} __attribute__ ((packed));

struct wave_block_header_t {
	u32 block;
	u32 size;
} __attribute__ ((packed));

struct wave_fmt_block_t {
	struct wave_block_header_t header;
	u16 compression;
	u16 num_channel;
	u32 sample_rate;
	u32 average;
	u16 block_align;
	u16 significant_bits;
	u16 extra_size;
	u16 extra_data;
} __attribute__ ((packed));

struct wave_data_block_t {
	struct wave_block_header_t header;
	u32 samples;
} __attribute__ ((packed));

struct sound_t {
	u32 loaded;
	u32 size;
	void *aligned_samples;
	s32 format;
	s32 pitch;
	struct wave_fmt_block_t *fmt;
};

void sound_init();
void sound_load_samples(struct sound_t *s, const u8 *file, u32 size);
void sound_load();
void play_sound(u32 sound, s32 delay, s32 sl, s32 sr);
void sound_end();

void sound_text();

#endif
